<template>
	<view>
		<template v-for="(item, index) in list" >
			<roleitem :cinfo="item"  :lvnum="lvnum"
			@TogCheck="ToglvCheck"
			@Togopen="Togopen(item)">
			</roleitem>
			<view
			v-if="item.isopen && (item.sons && item.sons.length)">
				<rolerecursion :list="item.sons"
				:lvnum="lvnum + 1"
				@toglvcheck="ToglvCheck"
				@togopen="Togopen"
				></rolerecursion>
			</view>
		</template>	
	</view>
</template>

<script>
	import roleitem from "./roleitem.vue"
	export default {
		name: 'rolerecursion',
		props: {
			lvnum: {
				type: Number,
				default: 1,
			},
			list: {
				type: Array,
				default: ()=> [],
			},
		},
		components:{
			roleitem,
		},
		methods: {
			ToglvCheck(obj){
				this.$emit('toglvcheck', obj)
			},
			Togopen(obj){
				this.$emit('togopen', obj)
			},
			
		},
	}
</script>

<style lang="scss" scoped>
	
</style>